import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        int x = cin.nextInt();
        int ans = 0;
        for(int i = 1; i <= n; i++){
            int[] base = {1,10,100,1000,10000,100000,1000000};
            for(int j : base){
                if(j>i) break;
                ans += i/j%10 == x ? 1 : 0;
            }
        }
        System.out.println(ans);
        cin.close();
    }
}